import os

from typing import List
from functools import lru_cache

ROOT_PATH = os.path.dirname(__file__)

class Config():
    # 目录
    PATH: str    = ROOT_PATH
    WEB_DIR: str = os.path.dirname(ROOT_PATH) + '/frontend'
    UPLOAD_DIR: str = ROOT_PATH + '/upload'
    # 应用配置
    DEBUG: bool  = True
    DOC_URL: str = "/docs"
    TITLE: str   = "高校课堂签到系统"
    DESCP: str   = "Web程序设计课程案例——高校课堂签到系统"
    VERSION: str = "1.0.1"
    # 启动配置
    HOST: str    = '0.0.0.0'
    PORT: int    = 9099
    RELOAD: bool = True
    # redis配置
    REDIS_HOST: str = "127.0.0.1"
    REDIS_PORT: int = 6379
    REDIS_DB  : int = 1
    REDIS_PASSWORD: str = "123123"
    # 数据库配置
    DB_USER: str = "root"
    DB_HOST: str = "127.0.0.1"
    DB_PORT: int = 3307
    DB_NAME: str = "web2025"
    DB_PASSWORD: str = "123123"
    # 跨域请求
    CORS_ORIGINS: List = ["*"]
    CORS_ALLOW_CREDENTIALS: bool = True
    CORS_ALLOW_METHODS: List = ["GET", "POST"]
    CORS_ALLOW_HEADERS: List = ["*"]
    # 允许的 hosts 列表
    AllowHosts: List[str] = ["127.0.0.1", "localhost"]
    # 排除认证接口
    WHITE_LIST: List[str] = []


@lru_cache()
def get_config():
    return Config()

if __name__ == '__main__':
    print(ROOT_PATH)